package com.example.demo.controller;

import com.example.demo.entity.User;
import com.example.demo.entity.UserInfos;
import com.example.demo.service.UserInfosSerice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/user_info")
public class UserInfoController {

    @Autowired
    private UserInfosSerice userInfosSerice;

    @RequestMapping("user_info_add")
    public String addOneInsert() {
        UserInfos userInfos = new UserInfos();
        userInfos.setUser_id(1157);
        userInfos.setCat("aodidiao");
        userInfos.setOrder_no("aodidiao12345646464654645");
        userInfos.setCreate_time(new Date());
        userInfos.setUpdate_time(new Date());
        userInfos.setIs_delete(2);
        int id = userInfosSerice.addUserInfo(userInfos);
        if (id != 0) {
            return "ok";

        } else {
            return "false";
        }
    }

    @RequestMapping("addmap")
    public String addMap() {
        Map<String,Object> map = new HashMap<>();
        map.put("user_id",331);
        map.put("cat",331);
        map.put("order_no",331);
        map.put("create_time",331);
        map.put("update_time",331);
        map.put("is_delete",1);
        int id =  userInfosSerice.addUserMap(map);
        if (id != 0) {
            return "ok";

        } else {
            return "false";
        }
    }
    @RequestMapping("select")
    public List<UserInfos> selectList(){
        List<UserInfos> selectall = userInfosSerice.selectall();
        return selectall;
//        List<User> users = userInfosSerice.userInfosSerice();
//        return users;
    }
}
